#ifndef UHIGHLIGHTER_H
#define UHIGHLIGHTER_H

#include "utkwidget_export.h"

#include <QSyntaxHighlighter>
#include <QTextCharFormat>
#include <QRegularExpression>

QT_BEGIN_NAMESPACE
class QTextDocument;
QT_END_NAMESPACE

class UTKWIDGET_EXPORT USyntaxHighlighter : public QSyntaxHighlighter
{
    Q_OBJECT
public:
    explicit USyntaxHighlighter(QTextDocument* parent);
    explicit USyntaxHighlighter(QObject* parent);
    ~USyntaxHighlighter();

protected:
    void highlightBlock(const QString &text) override;

    void initFormat();

private:
    struct HighlightingRule
    {
        QRegularExpression pattern;
        QTextCharFormat format;
    };
    QVector<HighlightingRule> highlightingRules;

    QRegularExpression commentStartExpression;
    QRegularExpression commentEndExpression;

    QTextCharFormat keywordFormat;
    QTextCharFormat classFormat;
    QTextCharFormat singleLineCommentFormat;
    QTextCharFormat multiLineCommentFormat;
    QTextCharFormat quotationFormat;
    QTextCharFormat functionFormat;
};

#endif // UHIGHLIGHTER_H
